/******************************************
 * Author: Dave Spadea
 * Date: June 2011
 * 
 * This code is released by David Spadea for general consumption 
 * under the Apache Software License.
 * 
 */

package net.spadea.sample;

import net.spadea.framework.messaging.Message;
import net.spadea.framework.messaging.exceptions.InvalidSensitivityException;
import net.spadea.sample.requests.*;

/* This sends an event into the controller so it can be picked up by the sample MyService service. */

public class SendRequest {

	public static void main(String[] args) throws InvalidSensitivityException {

		System.out.println("Sending SampleWorkflowEvent...");
		
		SampleWorkflowEvent swe = new SampleWorkflowEvent();
		
		swe.setTestKey("Some value");
		swe.send();
		
		System.out.println("Sent!");
		
		System.out.println("Sending PRIVATE SampleWorkflowEvent...");
		
		SampleWorkflowEvent pswe = new SampleWorkflowEvent();
		
		pswe.setTestKey("This should never wind up in the controller log.");
		pswe.setSensitivity(Message.SENSITIVITY_PRIVATE);
		pswe.send();
		
		System.out.println("Sent!");
		
		
		try {
			SampleWorkflowEvent2 pswe2 = (SampleWorkflowEvent2)pswe.convertTo(SampleWorkflowEvent2.class);
			System.out.println("PSWE2: " + pswe2.toString());
		} catch (InstantiationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
		System.exit(0);
		
	}

}
